package cn.schoolwow.quickdao.module.database.ddl.common.flow;

import cn.schoolwow.quickdao.domain.QuickDAOConfig;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class DeleteDatabaseEntityCacheFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        QuickDAOConfig quickDAOConfig = flowContext.checkInstanceData(QuickDAOConfig.class);
        String tableName = flowContext.checkData("tableName", String.class);

        quickDAOConfig.databaseContext.statementCache.entrySet().removeIf(entry -> entry.getKey().contains("_" + tableName + "_"));
        quickDAOConfig.databaseContext.databaseTableCache.remove(tableName);
    }

    @Override
    public String name() {
        return "删除数据库表缓存信息";
    }
}
